package bite;
import java.util.*;
/**
 * Creared with IntelliJ IDEA.
 * Description:【收件人列表】NowCoder每天要给许多客户写电子邮件。正如你所知，如果一封邮件中包含多个收件人，收件人姓名之间会用一个逗号和空格隔开；如果收件人姓
 * 名也包含空格或逗号，则姓名需要用双引号包含。
 * 现在给你一组收件人姓名，请你帮他生成相应的收件人列表。
 * User:yxd
 * Date:2022-06-10
 * Time:16:46
 */
public class Day34_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while(input.hasNextInt()) {
            int n = input.nextInt();
            input.nextLine();//吃掉上面nextInt的换行
            for(int i = 0;i < n;i ++){
                String name = input.nextLine();
                if(name.contains(" ") || name.contains(",")){
                    System.out.print("\"" + name + "\""); //需要两边加上引号
                }else{
                    System.out.print(name);
                }
                //如果是最后一个名字需要换行
                if(i == n - 1){
                    System.out.println();
                }else{
                    System.out.print(", ");//每个名字后面都得有一个", "
                }
            }
        }
    }
    public static void main1(String[] args) {
        Scanner input = new Scanner(System.in);
        while(input.hasNextInt()){
            int n = input.nextInt();
            List<String> list = new ArrayList<>();
            n ++;
            while(n-- != 0){
                String s = input.nextLine();
                StringBuilder stringBuilder = new StringBuilder();
                int i = 0;
                while(i < s.length() && s.charAt(i) != ' ' && s.charAt(i) != ','){
                    i ++;
                }
                if(i < s.length()){
                    stringBuilder.append('"');
                    stringBuilder.append(s);
                    stringBuilder.append('"');
                }else{
                    stringBuilder.append(s);

                }
                list.add(stringBuilder.toString());
            }
            list.remove(0);
            for (int i = 0; i < list.size(); i++) {
                if(i != list.size() - 1){
                    System.out.print(list.get(i) + ", ");
                }else{
                    System.out.println(list.get(i));
                }
            }
        }
    }

}
